package top.lvkun.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lvkun.basic.utils.RedisUtils;
import top.lvkun.user.domain.User;
import top.lvkun.user.domain.UserAddress;
import top.lvkun.user.service.IUserService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class UserController {

    @Autowired
    private IUserService userService;


    /**
     * 前台: 查询当前登录用户的地址们
     *
     * @return
     */
    @GetMapping("/userAddress")
    public List<UserAddress> getUserAddresses(HttpServletRequest request) {

        User user = RedisUtils.INSTANCE.getUser(request, User.class);
        return userService.getUserAddresses(user.getId());
    }

}
